package zuoye5.第一题;

/**
 * 使用 List 集合实现简易的学生信息管理系统，要求打印字符界面提示用户选择相应的功 能，根据用户输入的选择去实现增加、删除、修改、查找以及遍历所有学生信息的功能。
 *
 *  其中学生的信息有：学号、姓名、年龄。 要求： 尽量将功能拆分为多个.java 文件。
 */
//学生的entity类
public class StudentInformation implements java.io.Serializable{

    private static final long serialVersionUID = -6908183983083990585L;

    private int studentId;

    private String studentName;

    private int studentAge;

    public StudentInformation(){}

    public StudentInformation(int studentId, String studentName, int studentAge) {
        this.studentId = studentId;
        this.studentName = studentName;
        this.studentAge = studentAge;
    }

    public int getStudentId() {
        return studentId;
    }

    public void setStudentId(int studentId) throws StudentIdException {
        String studentIdReg = "^[0-9]{1,6}$";
        String studentId1 = studentId+"";
        if (!studentId1.matches(studentIdReg)){

            throw new StudentIdException("输入的Id不合理");

        }else {
            this.studentId = studentId;
        }
    }

    public String getStudentName() {
        return studentName;
    }

    public void setStudentName(String studentName) {
        this.studentName = studentName;
    }

    public int getStudentAge() {
        return studentAge;
    }

    public void setStudentAge(int studentAge) throws StudentAgeException {
        String studentAgeReg = "^[1-9][0-9]{0,2}$";
        String studentAge1 = studentAge+"";
        if (!studentAge1.matches(studentAgeReg)) {
            throw new StudentAgeException("输入的年龄不合理");
        }else {
            this.studentAge = studentAge;
        }
    }

    @Override
    public String toString() {
        return "StudentInformation{" +
                "studentId=" + studentId +
                ", studentName='" + studentName + '\'' +
                ", studentAge=" + studentAge +
                '}';
    }
}
